import React, { useState } from 'react';
import { Link, useParams, useLocation } from '@umijs/max';
import { Button } from 'antd';
import { PageContainer } from '@ant-design/pro-components';
import EditUser from './components/edit';

const UserSettings: React.FC = () => {
  const location = useLocation();
  const params = useParams();
  const user_id = params['user_id'] ? Number(params['user_id']) : 0;

  const [tab, setTab] = useState('base');

  return (
    <PageContainer
      header={{ title: '编辑运营账户' }}
      extra={[
        <Button key="back" type="primary">
          <Link to={{ pathname: `/user/list` }} state={location.state || {}}>
            返回
          </Link>
        </Button>,
      ]}
      tabList={[{ tab: '基本信息', key: 'base' }]}
      onTabChange={setTab}
    >
      {tab === 'base' && <EditUser title={'基本设置'} user_id={user_id} />}
    </PageContainer>
  );
};
export default UserSettings;
